'''
Author: angyi
Date: 2020-11-18 16:16:16
LastEditTime: 2020-11-20 10:34:03
LastEditors: Please set LastEditors
Description: 准备模型输入
FilePath: /Eddy/util/split_ocean_field.py
'''


import xarray as xr 
height = xr.open_mfdataset('../global_allsat/2020/*/*.nc',parallel=True)

ssh = height.sla.sel(latitude=slice(0,42),longitude = slice(100,142))


ssh_train = ssh.data[:300,:,:]
ssh_train.shape

ssh_test = ssh.data[300:,:,:]

ssh_test.shape

import numpy as np
np.save('model_data/test/ssha_test.npy',ssh_test)
np.save('model_data/train/ssha_train.npy',ssh_train)

np.save('../util/ssha_all.npy',ssh.data)


from dask.diagnostics import ProgressBar
delayed_obj = ssh.to_netcdf("all_year_height.nc", compute=False)
with ProgressBar():
    results = delayed_obj.compute()

